<!-- templates/students/add.html -->
{% extends "base.html" %}

{% block title %}添加学生{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header bg-primary text-white">
                    <h3 class="card-title mb-0">添加学生信息</h3>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('add_student') }}">
                        {{ form.hidden_tag() }}
                        
                        <!-- 学号 -->
                        <div class="form-group">
                            {{ form.student_id.label(class="form-label") }}
                            {% if form.student_id.errors %}
                                {{ form.student_id(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.student_id.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.student_id(class="form-control", placeholder="请输入学号（唯一标识）") }}
                            {% endif %}
                        </div>
                        
                        <!-- 姓名 -->
                        <div class="form-group">
                            {{ form.name.label(class="form-label") }}
                            {% if form.name.errors %}
                                {{ form.name(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.name.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.name(class="form-control", placeholder="请输入学生姓名") }}
                            {% endif %}
                        </div>
                        
                        <!-- 性别 -->
                        <div class="form-group">
                            {{ form.gender.label(class="form-label") }}
                            {% if form.gender.errors %}
                                {{ form.gender(class="form-select is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.gender.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.gender(class="form-select") }}
                            {% endif %}
                        </div>
                        
                        <!-- 出生日期 -->
                        <div class="form-group">
                            {{ form.birthdate.label(class="form-label") }}
                            {% if form.birthdate.errors %}
                                {{ form.birthdate(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.birthdate.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.birthdate(class="form-control", type="date") }}
                            {% endif %}
                        </div>
                        
                        <!-- 班级 -->
                        <div class="form-group">
                            {{ form.class_name.label(class="form-label") }}
                            {% if form.class_name.errors %}
                                {{ form.class_name(class="form-control is-invalid") }}
                                <div class="invalid-feedback">
                                    {% for error in form.class_name.errors %}
                                        <span>{{ error }}</span>
                                    {% endfor %}
                                </div>
                            {% else %}
                                {{ form.class_name(class="form-control", placeholder="请输入班级名称") }}
                            {% endif %}
                        </div>
                        
                        <!-- 提交按钮 -->
                        <div class="form-group text-center mt-4">
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-save me-2"></i>保存学生信息
                            </button>
                            <a href="{{ url_for('students') }}" class="btn btn-secondary btn-lg">
                                <i class="fas fa-times me-2"></i>取消
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}